home *** CD-ROM | disk | FTP | other *** search
- Path: hub.ymi.com!news
- From: Jeffrey Keays <keays@ymi.com>
- Newsgroups: comp.lang.c++,comp.os.ms-windows.programmer.tools.mfc
- Subject: Newbie question: default op=
- Date: Thu, 18 Jan 1996 11:34:12 -0800
- Organization: Young Minds, Inc.
- Message-ID: <30FEA0B4.4F66@ymi.com>
- NNTP-Posting-Host: 192.111.121.191
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (WinNT; I)
-
- I am trying to use the &*%$ MFC collections in some way that will dispose of its contents on destruction. In
- my 2-days and counting of ramming my head repeatedly against this brick wall over something that should be made
- 'easier' by them, I have this general C++ question.
-
- Why is it making me create operator= functions for assignment of the same type (or instance / reference of the
- same type). The class I'm trying to assign has no pointers or anything that would require special handling.
- Why do I have to write stupid things like
-
- class foo {
- int data1;
- double data2;
- CString data3;
- // ... ad infinitum
- public:
- foo& operator=(const foo &);
- }
-
- foo& foo::operator=(const foo &rhs)
- {
- data1 = rhs.data1
- data2 = rhs.data2
- data3 = rhs.data3
- // ... -- I should not have to write this, it should be ASSUMED
- // by the compiler if I don't specify otherwise.
- }
-
- The class i'm actually using is "Job", it has no data members that don't have their own appliance-ized helper
- functions (CString) or are simple types. The collection is "CList<Job, Job&> joblist", and here is my line
-
- joblist.AddTail(Job(p, wfd.cFileName));
-
- This is the line in MFC with the complaint,
-
- pNewNode->data = newElement;
-
- and this is the error.
-
- F:\MSDEV\MFC\include\afxtempl.h(813) : error C2582: 'Job' : 'operator =' function is unavailable
-
- Job has a two-argument constructor, as well as a do-nothing empty constructor I was forced against my will to
- add (I have found it documented that if you define any constructors, you lose the default constructor -- I have
- taken this as a given, since I don't know the rationale.)
- --
-